#include <pthread.h>

class Metux
{
public:
  Metux(pthread_mutex_t *lock)
      : _lock(lock)
  {
  }

  void Lock()
  {
    pthread_mutex_lock(_lock);
  }

  void Unlock()
  {
    pthread_mutex_unlock(_lock);
  }

  ~Metux()
  {
  }

private:
  pthread_mutex_t *_lock;
};

class LockGurad
{
public:
  LockGurad(pthread_mutex_t *lock)
      : _metux(lock)
  {
    _metux.Lock();
  }

  ~LockGurad()
  {
    _metux.Unlock();
  }

private:
  Metux _metux;
};